<template>
    <template v-for="item in menu">
        <el-sub-menu  v-if="item.children && (item.children.length) > 0 && item.children[0].menuType === '1'" :index="item.path" :key="item._id">
            <template #title>
                <el-icon>
                    <component :is="item.icon" />
                </el-icon>
                <span>{{item.menuName}}</span>
            </template>
            <tree-menu :menu="item.children" ></tree-menu>
        </el-sub-menu>
        <el-menu-item :index="item.path" v-else-if="item.menuType === '1'" :key="item._id">{{item.menuName}}</el-menu-item>
    </template>
</template>

<script setup name="TreeMenu">
    defineProps({
        menu: {
            type: Array,
            default: () => [],
        }
    })
</script>

<style scoped>

</style>
